package com.sunjob.loginserver.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.stp.StpUtil;
import com.sunjob.common.result.Result;
import com.sunjob.loginserver.service.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Wangzurong
 * @create 2022-08-07 1:11
 *  token 会话的控制器类
 */
@RestController
@CrossOrigin
@Api(value = "Token相关api",tags = "Token相关api")
public class TokenController {
    @Autowired
    TokenService tokenService;
    /**
     * 查询所有的tokenSession
     * @return
     */
    @ApiOperation(value = "查询所有TokenSession")
    @SaCheckPermission("monitor:satoken:query")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "satoken",value = "token",type = "header")
    })
    @GetMapping("/queryAllTokenSession")
    Result<List<SaSession>> queryAllTokenSession(){
        List<SaSession> saSessions = tokenService.queryAllTokenSession();
        return Result.ok(saSessions,"获取session列表成功");
    }

}
